package me.zhengjie.observer.resource;


import lombok.Getter;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Getter
@Component
public class EventExecutorResource {

    private final ExecutorService executor = new ThreadPoolExecutor(
            Runtime.getRuntime().availableProcessors() >> 1 > 0 ?
                    Runtime.getRuntime().availableProcessors() >> 1 : 1,
            Runtime.getRuntime().availableProcessors() << 1,
            30,
            TimeUnit.SECONDS,
            new LinkedBlockingQueue<>()
    );

}
